// ValidationAspects
// Written by Mike Saunders
// Released under Microsoft Public License (Ms-PL)
using System;
using ValidationAspects.Exceptions;
using ValidationAspects.Sdk;

namespace ValidationAspects.Factories
{
	public class Maximum : NumericValidatorFactoryBase
	{
		public double Value { get; set; }

		#region Overrides of NumericValidatorFactoryBase
		protected override Action<T, IValidationContext> GetValidateAction<T>(Func<T, double, int> compareFunc)
		{
			return (v, c) => { if (compareFunc(v, Value) > 0) throw new ValidateMaximumException(Value, v); };
		}
		#endregion
	}
}